package com.netstar.salesman_90dsp.tool;

import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.view.Window;

import com.squareup.timessquare.CalendarPickerView;

/**
 * 等待dialog
 * 
 * @author zhangshuai
 * 
 */
public class DateChooseDialog extends Dialog {
	/**
	 * 日历的id
	 */
	public int calendarId = -1;
	private Context context;
	/**
	 * 布局文件，view
	 */
	public View resLayoutView;
	/**
	 * 日期选择 控件
	 */
	public CalendarPickerView calendarPickerView;

	/**
	 * 自定义布局的构造方法
	 * 
	 * @param context
	 * @param resLayout
	 */
	public DateChooseDialog(Context context, int resLayoutId, int calendarId) {
		super(context);
		this.context = context;
		resLayoutView = View.inflate(context, resLayoutId, null);
		this.calendarId = calendarId;
		// 日历控件
		calendarPickerView = (CalendarPickerView) resLayoutView
				.findViewById(calendarId);
	}

	/**
	 * 自定义布局的构造方法
	 * 
	 * @param context
	 * @param resLayoutView
	 */
	public DateChooseDialog(Context context, View resLayoutView, int calendarId) {
		super(context);
		this.context = context;
		this.resLayoutView = resLayoutView;
		this.calendarId = calendarId;
		// 日历控件
		calendarPickerView = (CalendarPickerView) resLayoutView
				.findViewById(calendarId);
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		getWindow().requestFeature(Window.FEATURE_NO_TITLE);
		getWindow().setBackgroundDrawableResource(android.R.color.transparent);
		setOnShowListener(new OnShowListener() {

			@Override
			public void onShow(DialogInterface dialog) {
				calendarPickerView.fixDialogDimens();
			}
		});
		this.setContentView(resLayoutView);
	}

}
